Repository navigation
fix(driver-sql): distinct and aggregate group keys present a text boolean as find() does - #35332
Conversation
…lean as find() does presentReadValue's 'boolean' arm was Boolean(value), so a stored text '0' / 'false' (a TEXT-affinity boolean column, or legacy text a boot has not converged) presented as true in distinct() and aggregate() group keys while find() read it as false. The arm now calls presentStoredBoolean, the function formatOutput applies. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
… false as false Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Ca1jJvsA1dHsPwMiQb
📓 Docs Drift Check2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 15 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin c12f12ff7f15e0a2992f03bd7cfbc5a5bf100f7b && git checkout c12f12ff7f15e0a2992f03bd7cfbc5a5bf100f7b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 81c09477981398c908cc282e7c2c9a0fec884278 c057c311b4f8ed3b8ec8230b0fe6272fa003f756 && git checkout -B drift-repro 81c09477981398c908cc282e7c2c9a0fec884278 && git merge --no-ff c057c311b4f8ed3b8ec8230b0fe6272fa003f756
node scripts/docs-audit/affected-docs.mjs --json 81c09477981398c908cc282e7c2c9a0fec884278 |
|
repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb Final head for review · area data-1 · 2026-11-19T05:41Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head
|
|
repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb Landing · area data-1 · 2026-11-19T05:44Z
State: draft → ready + auto-merge (merge queue). #34974 closes on merge via |
Fixes #34974
Clause-②: no
Metadata-protocol: none
维护者速读
distinct()和聚合分组键里,存储的文本'0'/'false'现在显示为false,'1'/'true'显示为true,与记录读取(find())完全一致;用的是记录读取同一个函数,不是另写一套规则。Boolean(value),文本'0'会被当成true。对于由文本字段改成布尔字段的列(SQLite 保留 TEXT 亲和性),所有未勾选的行在仪表盘分组里都会算进true桶,distinct也只答[true]。packages/drivers/driver-sql/src/sql-driver-filter-helpers.ts(presentReadValue的'boolean'分支)、packages/drivers/driver-sql/src/sql-driver-sqlite-serialisation.ts(presentStoredBoolean改为导出)、packages/drivers/driver-sql/src/sql-driver-34974-boolean-read-presenter.test.ts。pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-34974-boolean-read-presenter.test.ts,预期 10 个测试全部通过。What changes
sql-driver-filter-helpers.ts:presentReadValue's'boolean'arm callspresentStoredBoolean, the functionformatOutputapplies to afind()row (Inline grid edit stores a boolean field as the text 'true' (SQL driver) — equality filters miss it and requiredWhen reads it as false #34916).0/'0'/'false'/falsepresent asfalse;1/'1'/'true'/trueastrue; any other value keeps theBoolean(value)reading it had. This makes the class docblock's contract true again: one presenter per kind, the functionformatOutputitself calls, never a re-derivation.sql-driver-sqlite-serialisation.ts:presentStoredBooleangainsexportand one docblock sentence naming its second caller. Nothing else in the file moves.distinct()presents throughpresentReadValuedirectly, andaggregate()group keys (plain and aliased) throughpresentReadColumns, which callspresentReadValue.min/max/sum/avgover a boolean still skip the boolean kind and answer a number, as the driver-sql: boolean aggregands need a lowering cast on PG (+ a MySQL min/max presentation check) — the ruledfalse/true+ arithmetic answers are unproducible on the PG face #11635 ruling says.sql-driver-34916-boolean-text-read.test.ts: the[#34973]groupBy pin's "before the convergence" half asserted the defect this card fixes (the text'false'group presenting astrue). It now asserts that group presents asfalse. The after-convergence half is unchanged.@objectstack/driver-sqlpatch.Tests
New file
packages/drivers/driver-sql/src/sql-driver-34974-boolean-read-presenter.test.ts, 10 tests on two columns:'true'/'false'written past the driver, not yet converged): fixture storage types,find()as the reference,distinct()answers[false, true], group key and aliased group key present the text'false'asfalse.flag textcolumn, legacy'false'/'true'plus a'0', then a boot): the fixture shows the boot leaves every cell as the text'0'/'1';find()as the reference;distinct()answers[false, true]; group key and aliased group key count[[false, 3], [true, 1]].Reading first: the TEXT-affinity case live on SQLite, before the fix (origin/main de8d549)
The new file run against the unfixed presenter: 6 failed, 4 passed. The fixture and
find()pins pass, and everydistinct/ group-key pin fails:Ablation (one, on the committed fix)
node scripts/ablation-replace.mjsswappedreturn presentStoredBoolean(value);back toreturn Boolean(value);insql-driver-filter-helpers.ts: anchor x1 to x0, blob6ec738601beeto77d0e0a57de7. Result: the new file goes 6 failed / 4 passed, the same six pins as the reading above. Restore: blob back to6ec738601bee, equal to HEAD, andgit diff HEADempty. The test imports./sql-driver.jsfromsrc, so nodistrebuild was involved.Package suite
pnpm --filter @objectstack/driver-sql test: Test Files 264 passed, 13 skipped (277); Tests 4397 passed, 257 skipped (4654).pnpm --filter @objectstack/driver-sql typecheck: exit 0.tsc --listFilesincludes the new test file (1 hit).Acceptance notes
readPresentationKindalready returned'boolean'for a declared boolean on SQLite / MySQL / Oracle, so the card body's "no boolean kind" was stale. The live defect was theBoolean(value)arm, as the triage widening said.0/1for a legacy'false'/'true', and the affinity stores that as the text'0'/'1'. It leaves the text'0'/'1'in place on purpose, because those already read correctly on a row. So a TEXT-affinity column holds'0'after every boot.texttobooleankeeps itsTEXTcolumn after the boot (pragma_table_inforeadsTEXTbefore and after). The driver's owncreate(…, { flag: false })then stores the text'0.0'(better-sqlite3 binds the number as REAL), andfind()presents it astrue, along withdistinct()and group keys. The same column also misses'0'rows onflag = false. This is out of this card's scope: fixing it means either reading'0.0'/'1.0'as booleans in the shared presenter, which changesfind()and adds a new truthiness rule, or converging or rebuilding the column's storage. That is a design choice, so it goes to the seat in the report.Verification
Local gates and CI check-runs are cited in the os-dev report on the card.
node scripts/pm/overlap-check.mjs --branch=HEAD: clean, exit 0.Generated by Claude Code